#include "FiniteStateMachine.h"

void changeSize(int w, int h)
{
	FSM::GetInstance()->changeSize(w, h);
}

void renderScene(void) 
{
	FSM::GetInstance()->renderScene();
}

void inputKey(int key, int x, int y) 
{
	FSM::GetInstance()->inputKey(key, x, y);
}

void KeyboardDown(unsigned char key, int x, int y)
{
	FSM::GetInstance()->KeyboardDown(key, x, y);
}

void KeyboardUp(unsigned char key, int x, int y)
{
	FSM::GetInstance()->KeyboardUp(key, x, y);
}

void MouseMove(int x, int y)
{
	FSM::GetInstance()->MouseMove(x, y);
}

void MouseClick(int button, int state, int x, int y)
{
	FSM::GetInstance()->MouseClick(button, state, x, y);
}

void CleanUpUponExit(void)
{
	FSM::GetInstance()->Exit();
}

void Update(void)
{
	FSM::GetInstance()->Update();
}

int main(int argc, char **argv)
{
	//FreeConsole();
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(250, 50);
	glutInitWindowSize(800, 600);
	glutCreateWindow("AI Assignment 1");

	glutReshapeFunc(changeSize);

	glutDisplayFunc(renderScene);
	//glutFullScreen();
	glutIdleFunc(Update);

	//	glutSpecialFunc(inputKey);
	glutKeyboardFunc(KeyboardDown);
	glutKeyboardUpFunc(KeyboardUp);
	glutPassiveMotionFunc(MouseMove);
	glutMouseFunc(MouseClick);// for mouse click

	atexit(CleanUpUponExit);

	if (FSM::GetInstance()->Init() == true)
	{
		glutMainLoop();
	}
	else
	{
		printf("Error Initialising Program\n");
		return 1;
	}

	return 0;
}